﻿#region Copyright Info

// 
// Majesty of Omega - The next evolution of macro management space strategy
// 
// Copyright 2007-2009 André Claaßen
// 
// This file is protected by the terms and conditions of the
// Microsoft Community License (Ms-CL 1.1), a copy of which should
// have been distributed along with this software. If not,
// you may find the license information at the following URL:
// 
// http://www.microsoft.com/resources/sharedsource/licensingbasics/communitylicense.mspx

#endregion

#region

using System.Windows.Controls;
using DesignByContract;
using Majesty_of_Omega.Logic.GameConfiguration;
using Majesty_of_Omega.Model.Game;
using Majesty_of_Omega.Config;
using Majesty_of_Omega.GUI.Pages.Game;

#endregion

namespace Majesty_of_Omega.GUI.Controller
{
    /// <summary>
    /// Controller for setting up a new game.
    /// </summary>
    /// <remarks>
    /// this controller will be instantiated in the last setup page (Step3_GameSettings.xaml)
    /// </remarks>
    public class NewGameController : Controller
    {
        ///<summary>
        /// constructor for the controller
        ///</summary>
        public NewGameController(Page page) : base(page)
        {
        }

        /// <summary>
        /// Constructor for unit test purposes
        /// </summary>
        /// <param name="bInUnitTest">true, when the controller is in unit test mode</param>
        public NewGameController(bool bInUnitTest)
            : base(null)
        {
            Require.IsTrue(bInUnitTest);
        }

        ///<summary>
        /// Creates a new game and navigate to GalaxyPage.xaml
        ///</summary>
        public void CreateNewGame()
        {
            GameGenerator gameGenerator = new GameGenerator(GameConfigurator.GameSettings);
            SaveGame game = gameGenerator.GenerateNewGame();
            game.SetCurrent();
            Navigate(new GalaxyPage(new GalaxyPageController(game)));
        }

        /// <summary>
        /// Sets the Galaxy Configuration
        /// </summary>
        /// <param name="configurationsGalaxy">A configuration object out of the xml fgile</param>
        public void SelectGalaxyConfiguration(GalaxyConfigurationsGalaxy configurationsGalaxy)
        {
            GameConfigurator.GameSettings.GalaxyConfiguration = configurationsGalaxy;
        }
    }
}